package socket.socketandserversocket;

import java.io.*;
import java.net.Socket;

public class Demo01Cilent {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("127.0.0.1", 8080);
        System.out.println("客户端已经连接上服务器，可以互相通信");
        BufferedOutputStream bos;
        bos = new BufferedOutputStream(socket.getOutputStream());
        BufferedInputStream bis;
        while (true) {
            bis = new BufferedInputStream(socket.getInputStream());
            WriteThread writeThread = new WriteThread(bos);
            ReadThread readThread = new ReadThread(bis);
            new Thread(writeThread, "客户端").start();
            new Thread(readThread, "客户端").start();
        }
    }
}
